import config from '@arcgis/core/config';

// 配置基础路径
config.assetsPath = './assets';

// // 配置 worker 加载器路径
// config.workers.loaderUrl = new URL(
//   'node_modules/@arcgis/core/workers/loader.js', 
//   import.meta.url
// ).href;

// 设置 API 密钥（可选）
config.fontsUrl = '/assets/esri/themes/base/fonts'
config.apiKey =
  'AAPK4fca9f2ecd52420eaa3999caf4564aebmOMdabD74JMoeUFUL0QUbhzbIUTdxJI0cyx5aU4rEu3XUXB-OohSYFgPEtbv7eNU'
config.geometryServiceUrl =
  'http://16.37.64.24:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer'


// 预加载关键模块
export function preloadArcGISModules() {
  return Promise.all([
    import('@arcgis/core/Map'),
    import('@arcgis/core/views/MapView')
  ]);
}

// 按需加载模块
export async function loadArcGISModule(modulePath: string) {
  const module = await import(
    /* @vite-ignore */
    `@arcgis/core/${modulePath}`
  );
  return module.default || module;
}